package com.yu.crm.enums;

import com.yxzz.common.exception.ValidateException;

/**
 * 条件枚举
 */

public enum ComditionStatus {

    NUMBER("number", "数量");

    private String key;
    private String value;

    ComditionStatus(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static boolean validate(String key) {
        for (ComditionStatus o : ComditionStatus.values()) {
            if (key .equals(o.getKey())) {
                return true;
            }
        }
        throw new ValidateException("无效的审批状态:" + key);
    }

    public static String getKeyByValue(String value) {
        for (ComditionStatus o : ComditionStatus.values()) {
            if (value.equals(o.value))
                return o.key;
        }
        return null;
    }

    public static String getValueByKey(String key) {
        for (ComditionStatus o : ComditionStatus.values()) {
            if (key.equals(o.key))
                return o.value;
        }
        return null;
    }

}
